package com.viewfin.common.strategy;

import java.time.LocalDateTime;

public class SimpleRunable implements Runnable {

    private  Integer sign;

    public void setSign(Integer sign) {
        this.sign = sign;
    }

    @Override
    public void run() {

        try {

            int i=0;

            while (true){
                System.out.println(Thread.currentThread().getName()+":"+sign+"次:"+LocalDateTime.now());

                Thread.sleep(1000);

                if (i == 3){
                    throw new InterruptedException("");
                }
                i++;
            }



        }catch (InterruptedException e){

            System.out.println(Thread.currentThread().getName()+"线程中断,正在恢复");
            SimpleRunable simpleRunable = new SimpleRunable();
            simpleRunable.setSign(sign);
            new Thread(simpleRunable).start();
        }


    }
}
